# ruby exercise - basic II
# mario hsieh

nums = [3,5,1,2,7,9,8,13,25,32]

def sum(num)
	total = 0
	array = []
	range = 0...num.length

	for i in range
		temp = num[i].to_i
		total += temp

		if temp > 10
			array.push(num[i])
		end
	end
	puts total
	puts array.to_s
end

sum(nums)


#############################################


names = ["John", "KB", "Oliver", "Cory", "Matthew", "Christoper"]

def arrayallday(array)
	puts array.shuffle.to_s
	temp = []

	for i in 0...array.length
		if array[i].length > 5
			temp.push(array[i])
		end
	end

	puts temp.to_s
end

arrayallday(names)


###################################################


alphabet = ('a'..'z').to_a
puts alphabet.shuffle.last

firstletter = alphabet.shuffle.first
puts firstletter
if firstletter == 'a' || firstletter == 'e' || firstletter == 'i' || firstletter == 'o' || firstletter == 'u'
	puts "this letter is a vowel"
end


########################################################

def array_gen(num)
	array = []
	for i in 0...num
		array.push(rand(55..100))
	end
	puts array.to_s
end

array_gen(10)

######################################################


def new_array_gen(num)
	array = []
	for i in 0...num
		array.push(rand(55..100))
	end
	array = array.sort
	puts array.to_s
	puts array.min
	puts array.max
end

new_array_gen(10)


##########################################################

def random_string(num)
	string = ""
	for i in 0...num
		string += (65+rand(26)).chr
	end
	puts string
end

random_string(5)


##########################################################


def random_array(quantity, length)
	array = []

	for i in 0...quantity
		string = ""
		for j in 0...length
			string += (65+rand(26)).chr
		end
		array.push(string)
	end
	puts array.to_s
end

random_array(10,5)



